﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using FrontRoomCheck.Model;
using FrontRoomCheck.Properties;
using FrontRoomCheck.ShowDataForm.FrontRoomAreaCheck;
using FrontRoomCheck.Utiltiy;
using YArchitech.Controls;
using ModelCheckUtility.ModelLayer;

namespace FrontRoomCheck.SpecialUse
{
	public class ResutlShow_CmdFrontRoomSurfaceCheck : IResutlShow<ICloseCurveAnalays>, IPackerResutlShow<ICloseCurveAnalays>, IBase<ICloseCurveAnalays>
	{
		public void ShowResults(List<ICloseCurveAnalays> input, params object[] otherValues)
		{
			if (input == null)
			{
				return;
			}
			string guid = Resources.GUID;
			string areaGuid = Resources.AreaGuid;
			InsertArea insertArea = new InsertArea();
			InsertData insertData = new InsertData();
			FrontRoomCheck_CmdFrontRoomSurfaceCheck frontRoomCheck_CmdFrontRoomSurfaceCheck = new FrontRoomCheck_CmdFrontRoomSurfaceCheck();
			ExternalCommandData cmdData = StaticRescource.CmdData;
			UIDocument activeUIDocument = cmdData.Application.ActiveUIDocument;
			for (int i = 0; i < input.Count; i++)
			{
				Element thisElement = input[i].GetThisElement();
				insertData = InsertDataToRoom.ReadFromElement<InsertData>(thisElement, guid);
				input[i].RoomType = insertData.FrontRoomType;
				input[i].BuildingType = StaticRescource.BuildingTypes[1];
				if (frontRoomCheck_CmdFrontRoomSurfaceCheck.doCheckFrontChamberStandard(input[i]))
				{
					input.Remove(input[i]);
					i--;
				}
			}
			for (int j = 0; j < input.Count; j++)
			{
				Element thisElement2 = input[j].GetThisElement();
				insertArea = InsertDataToRoom.ReadAreaFromElement<InsertArea>(thisElement2, areaGuid);
				if (insertArea.m_RoomArea != 0.0)
				{
					input.Remove(input[j]);
					j--;
				}
			}
			if (input.Count == 0)
			{
				YJKMessageBox.Show("您所检测的楼层中，前室面积全部符合规范要求");
				return;
			}
			try
			{
				AreaCheckViewLayerManger areaCheckViewLayerManger = new AreaCheckViewLayerManger();
				areaCheckViewLayerManger.DoViewLayer(cmdData, StaticRescource.m_hWndRevit, activeUIDocument, input);
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message, "盈建科提示");
			}
		}
	}
}
